﻿Public Class frmNha

  
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim sql As String = "select * from Nha"
        Dim DATA As New ketnoidulieu()
        dgvnha.DataSource = DATA.ExcuteDataTable(sql)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim sql As String = String.Format("select * from Nha where  DiaChi=N'{0}' or SoTien='{1}'", txtdc.Text, txtmn.Text)
        Dim DATA As New ketnoidulieu()
        dgvnha.DataSource = DATA.ExcuteDataTable(sql)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim sql As String = String.Format("Insert into Nha(MaNha, DiaChi, SoTien) values ('" & txtmanha.Text & "','" & txtdiachi.Text & "', '" & txtsotien.Text & "')")
        Dim INS As New ketnoidulieu()
        INS.SQL_ExecuteNonQuery(sql)
        Dim sl As String = "select * from Nha"
        dgvnha.DataSource = INS.ExcuteDataTable(sl)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If txtmanha.Text = "" Then
            MsgBox(" Bạn Phải Nhập Giá Trị Cấn Xóa !!! ")
        Else
            Dim sql As String = String.Format("delete * from Nha where MaNha = '" & txtmanha.Text & "'")
            Dim KN As New ketnoidulieu()
                KN.SQL_ExecuteNonQuery(sql)
            Dim sl As String = "select * from Nha"
            dgvnha.DataSource = KN.ExcuteDataTable(sl)
        End If
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim sql As String = String.Format("Update Nha Set  DiaChi = N'{0}', SoTien ='{1}' where MaNha = '" & txtmanha.Text & "'", txtdiachi.Text, txtsotien.Text)
        Dim INS As New ketnoidulieu()
        INS.SQL_ExecuteNonQuery(sql)
        Dim sl As String = "select * from Nha"
        dgvnha.DataSource = INS.ExcuteDataTable(sl)
    End Sub
End Class